﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cecbData;

namespace Dss.Methods
{
    public class GenarateExcel
    {
        public GenarateExcel() 
        {

            cecbContext = new DSSEntities();
        }

        DSSEntities cecbContext;

        public List<Members> getAllMemberNames( String teamId)
        {
            IQueryable<Members> query = from c in cecbContext.Members
                                        join b in cecbContext.TeamMembers on c.mem_reference equals b.mem_reference
                                        where b.team_reference == teamId
                                        select c;

            List<Members> Memdetails = query.ToList();

            return Memdetails;
        }

        public List<Impacts> getProjectComponents(String projId,String compID)
        {
            String xcom = cecbContext.Components.First(i => i.cmpt_name.Contains(compID)).cmpt_reference;

            IQueryable<Impacts> query = from c in cecbContext.Impacts
                                        join b in cecbContext.ProjectImpacts on c.impt_reference equals b.impt_reference
                                        where b.proj_reference == projId && c.impt_component == xcom
                                        select c;

            List<Impacts> ProComp = query.ToList();

            return ProComp;
        }

        public List<Activities> getProjectActivities(String projId)
        {
            //String xcom = cecbContext.Components.First(i => i.cmpt_name.Contains(compID)).cmpt_reference;

            IQueryable<Activities> query = from c in cecbContext.Activities
                                        join b in cecbContext.ProjectActivities on c.actv_reference equals b.actv_reference
                                        where b.proj_reference == projId 
                                        select c;

            List<Activities> ProComp = query.ToList();

            return ProComp;
        }


        //public List<Components> getProjectComponents(String projId, String compID)
        //{
        //    String xcom = cecbContext.Components.First(i => i.cmpt_name.Contains(compID)).cmpt_reference;

        //    IQueryable<Components> query = from c in cecbContext.Impacts
        //                                join b in cecbContext.ProjectImpacts on c.impt_reference equals b.impt_reference
        //                               // join a in cecbContext.Components on a.cmpt_reference equals c.impt_component
        //                                where b.proj_reference == projId && c.impt_component == xcom
        //                                select c;

        //    List<Components> ProComp = query.ToList();

        //    return ProComp;
        //}

    }
}
